﻿/*
Replication File 
Last updated by Eric Plutzer 06.24.2018

Email: plutzer@psu.edu; lee.hannah@wright.edu 


Updates by LH on 06.11.2018 and 06.19.2018 - Includes adding 'teaching consensus' and 'encouraging debate' (~line 264)
And adds labels to graphs that correspond to supplementary appendix and text.

Update by EXP 06.24.2018 dropping consens_ord from calculation of know_miss_count

*/


**
/* Read in replication data file from 
Plutzer, Eric, Mark McCaffrey, A. Lee Hannah, Joshua Rosenau, Minda Berbeco, and Ann
Reid. 2016. “Climate confusion among U.S. teachers.” SCIENCE Vol. 351 (no. 6274):664-665.
DOI: 10.1126/science.aab3907
*/


*cd "PATH FILE NAME HERE"
*use "Climate_Confusion_Replication_February2016_Release_v12.dta"

**** ADMIN AND SAMPLING VARIABLES

* SUBJECT TAUGHT
* Make middle school the reference group
replace subject = 0 if subject == 5
label define labsample 0 "Middle school" 1 "HS Biology" 2 "HS Earth Science" 3 "HS Physics" 4 "HS Chemistry"
label values subject labsample
tab subject


** Integer weight to use for histograms
gen int_wt = (round(anal_wt *100),1)
svyset [pw = anal_wt], strat(subject)


*********************************************
**********	INDEPENDENT VARIABLES  **********


* INSTRUCTION ON CLIMATE CHANGE
tab ed_summary [aw=anal_wt]

/*
 ed_summary |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 | 819.444156       57.14       57.14 None at all (57.14%)
          1 | 247.406014       17.25       74.40 Only one class covered the topic (17.25%)
          2 |133.2741657        9.29       83.69 Two or more courses covered topic (9.29+2.41+2.90 =
          3 |34.52587018        2.41       86.10
          4 | 41.5611492        2.90       89.00
         10 | 5.25002863        0.37       89.36 One course entirely focused on cc (96.67 - 89.0 = 6.67
         11 | 37.3444999        2.60       91.97
         12 | 31.7003946        2.21       94.18
         13 | 11.3187707        0.79       94.97
         14 | 17.9383818        1.25       96.22
         20 | 5.11221371        0.36       96.57  Two or omre courses (100 - 96.22 = 3.8)
         21 |1.369845542        0.10       96.67
         22 | 18.4702964        1.29       97.96
         23 | 1.87170486        0.13       98.09
         24 | 10.9505471        0.76       98.85
         30 | 1.10052325        0.08       98.93
         33 |  2.6866272        0.19       99.12
         34 | .304888091        0.02       99.14
         40 | 1.17500056        0.08       99.22
         42 | .873129192        0.06       99.28
         44 |10.32179345        0.72      100.00
------------+-----------------------------------
      Total |      1,434      100.00

*/

**** Collapsed version of class exposure variable

/*      college_summary |      Freq.     Percent        Cum.
----------------------+-----------------------------------
                 None | 819.444156       57.14       57.14
         One exposure | 247.406014       17.25       74.40
Two or more exposures | 209.361185       14.60       89.00
     One entire class |103.5520756        7.22       96.22
           2+ classes | 54.2365693        3.78      100.00
----------------------+-----------------------------------
                Total |      1,434      100.00

*/


label define course 0 "Never instructed", modify
tab college_summary [aw=anal_wt]

* COLLEGE AND GRADUATE DEGREES

/* Educational achievement
We classify all surveyed teachers based on their reported college and graduate degrees earned.  
Over 70% hold a bachelor’s of science degree and a quarter of those who do not, earned a master’s in a scientific field.  
For the purposes of this paper, we computed the following variables to classify teachers’ formal educational achievements.  

noscience_degree is coded to 1 for those who do not hold any degrees in a scientific field.  
These represent about 30% of all middle school science teachers and about 15% of all high school teachers. 

gradscience_degree is coded 1 for all teachers who hold a masters or doctoral degree in science (about one in four high school teachers, and one in eight middle school teachers).  

Finally, more than half of teachers at every level have a master’s of doctorate of education. 

othgrad_degree is coded 1/0 

These are not interpretable as dummy codes because about 4% of teachers are coded “1” for both graduate science and graduate education.

Missing:
29 individuals did not answer the degree earned questions which appeared near the end.  
An additional 40 teachers who answered this question left the questions on specific coursework blank.

*/

gen noscience_degree = 0
replace noscience_degree = 1 if (q20_bachscience + q20_mastersci + q20_phdscience) == 0
tab subject noscience_degree, row

gen gradscience_degree = 0
replace gradscience_degree = 1 if (q20_mastersci + q20_phdscience) >=1

gen othgrad_degree = 0
replace othgrad_degree = 1 if (q20_mastered + q20_doctored) >=1

label variable noscience_degree "No degree in science"
label variable gradscience_degree "Grad degree in science"
label variable othgrad_degree "Grad degree-other"
tab1 *_degree



* FEMALE
gen female =0
replace female = 1 if q27_gender == 2
label variable female "Female"
sum female [aw = anal_wt]

* SENIORITY
label variable q25_yrsteach "Years teaching"
sum q25_yrsteach [aw = anal_wt]


label variable q28_black "African American"
label variable q28_hisp  "Hispanic"


* PID 
gen left_party = .
* Tea Party and Libertarian
replace left_party = 1 if q31_party == 5
replace left_party = 1 if q31_party == 6
*Republicans and non-green others
replace left_party = 2 if q31_party == 3
replace left_party = 2 if q31_party == 7
*Independents
replace left_party = 3 if q31_party == 2
*Democrats and Greens
replace left_party = 4 if q31_party == 1
replace left_party = 4 if q31_party == 4

tab q31_party left_party

label define pidl 1 "Libertarian & Tea Party" 2 "Republican" 3 "Independent" 4 "Democrat & Green"
label values left_party pidl

label variable q19_govrole "Active role for govt"

* ORIGINAL AND REVERSE CODED BIBLE MEASURE
gen fables = .5 * ((q30_bible) -1 )
gen bible = (-1 * fables) + 1
tab bible





*********************************************
**********	MEDIATING  VARIABLE  ************
**********	 CONTENT KNOWLEDGE   ************


/* Based on four components:

	1. Self-rated expertise
	2. Absence of misconceptions, as indicated by foils
	3. Limited knowledge relfected in DK's to Q8
	4. Understands relevance of shortwave vs longwave energy
*/

* 1. SELF RATED EXPERTISE

tab q23_climate
sum q23_climate [aw = anal_wt]

* 2. Number of foils correctly answered (q8) in which we score 
**     correct answers = 1, and guesses and "priority" answers are coded 0.


* SUM OF I DON'T KNOW'S ON Q8
egen missing_count_q8_ = rowmiss(q8*)
tab missing_count_q8_
gen allmissing_q8 = 0
replace allmissing_q8 = 1 if missing_count_q8_ == 10


gen correct_aerosol=0
gen correct_ozone = 0
gen correct_pesti = 0
gen correct_rocket= 0
gen correct_wave= 0

replace correct_aerosol=1 if q8_aerosol == 3 
replace correct_ozone = 1 if q8_ozone   == 3
replace correct_pesti = 1 if q8_pestic  == 3
replace correct_rocket= 1 if q8_rockets == 3
replace correct_wave= 1   if q8_wave == 2
replace correct_wave =  1 if q8_wave == 1.5

replace correct_aerosol=2 if q8_aerosol == 4 
replace correct_ozone = 2 if q8_ozone   == 4
replace correct_pesti = 2 if q8_pestic  == 4
replace correct_rocket= 2 if q8_rockets == 4
replace correct_wave =  2 if q8_wave == 1

replace correct_aerosol=. if allmissing_q8 == 1
replace correct_ozone = . if allmissing_q8 == 1
replace correct_pesti = . if allmissing_q8 == 1
replace correct_rocket= . if allmissing_q8 == 1
replace correct_wave = . if allmissing_q8 == 1

tab1 correct_*
sum correct_*


alpha correct_aerosol correct_ozone correct_pesti , std item detail 
polychoric correct_aerosol correct_ozone correct_pesti [aw = anal_wt]

egen foils_correct = rowtotal(correct_aerosol correct_ozone correct_pesti)
tab foils_correct

*/

** 3. DKs to relevant Q8 questions (excluding waveliength question

foreach var of varlist q8* {
replace `var'= . if `var'==5
}


egen dk_count_5nofoils = rowmiss(q8_forests q8_co2 q8_homes q8_coaloil q8_emissions)
replace dk_count_5nofoils = . if allmissing_q8 == 1
tab dk_count_5nofoils
gen answered_5q8nofoils = 5 + (-1* dk_count_5nofoils)
tab1 answer*

** 4. Correct wavelength
tab correct_wave


* SUM OF I DON'T KNOW'S ON Q8
misstable patterns q23_climate foils_correct answered_5q8nofoils correct_wave
egen know_miss_count = rowmiss(q23_climate foils_correct answered_5q8nofoils correct_wave)
tab know_miss_count



**** SCALING - * takes a z score of all inputs and averages them
alpha q23_climate  foils_correct answered_5q8nofoils correct_wave if know_miss_count <3, std detail item gen(know4_std)
*polychoric q23_climate   foils_correct answered_5q8nofoils correct_wave
* alpha is 0.45, mean r = .17, mean polychoric  = .26, so ordinal alpha is (.26/.17)*.45 = 0.69


egen tempmin = min(know4_std)
egen tempmax = max(know4_std)

gen know4_00 = 100 * (round (  (know4_std - tempmin )/ ( tempmax-tempmin) ) ,.001)
label variable know4_00 "Subject Content Knowledge"

** FIGURE S1: Distribution of Subject Content Knowledge of Climate Change of Middle and High School Teachers
histogram know4_00 [fw=int_wt], bin(14) percent xscale(range(0 100)) scheme(s1mono)




***************************************
********  DEPENDENT VARIABLES  ********



** Constructing number of hours taught variable.
gen q1_num_globalwarm = q1_globalwarm


**** MULTIPLE PUNCH RESPONDENT INDICATED ON VERIFICATION LOGS
** SRCID=="12644" scored 1 and 4 (none and 6-10) but answered extensively on Q3
replace q1_globalwarm = 4 if SRCID=="12644" 


foreach var of varlist q1_num_globalwarm*{
recode `var' 1 = 0
recode `var' 2 = 1.5
recode `var' 3 = 4
recode `var' 4 = 8
recode `var' 5 = 13
recode `var' 6 = 18
recode `var' 7 = 25
}

*
tab q1_num_globalwarm



**********************/
/** EMPHASIZE THE CONSENSUS

1 = Strongly Agree to 4 = Strongly Disagree

a. I emphasize that average global temperatures have risen in the last 150 years.
c. I emphasize the scientific consensus that recent global warming is primarily being caused by human release of greenhouse gases from fossil fuels.

Unadjusted Cronbach’s alpha = 0.81
Pearson corr = 0.676
Polychoric corr = 0.778, or 15% higher

So ordinal alpha = .93
*/

foreach var of varlist q4* {
replace `var'= . if `var'==5
}


alpha q4_globaltemp q4_sciconsensus, std item detail
polychoric q4_globaltemp q4_sciconsensus

gen teach_consensus = (100/6) * ((-1*(q4_globaltemp + q4_sciconsensus))+8)
label variable teach_consensus "Emphasizes warming is real & anthropogenic"
tab teach_consensus


** FIGURE S2: Distribution of scores on the emphasize the consensus scale

histogram teach_consensus [fw=int_wt], bin(5) percent xscale(range(0 100)) scheme(s1mono)


/* PERMIT/ENCOURAGE DEBATE 

1 = Strongly Agree to 4 = Strongly Disagree

e. I encourage students to debate the likely causes of global warming. 
f. I encourage students to come to their own conclusions about the causes of global warming. 

Unadjusted Cronbach’s alpha = 0.76
Pearson corr = 0.618
Polychoric corr = 0.714, or 16% higher

So ordinal alpha = .88
*/

alpha q4_debate q4_ownconclusions, std item detail
polychoric q4_debate q4_ownconclusions
gen teach_with_debate = (100/6) * ((-1*(q4_debate + q4_ownconclusions))+8)
label variable teach_with_debate "Encourages debate and own conclusions on causes"
sum teach_with_debate

** FIGURE S3: Distribution of scores on encourage debate scale
histogram teach_with_debate [fw=int_wt], bin(5) percent xscale(range(0 100)) scheme(s1mono)


** TABLE S1: Distribution of correlations among dependent variables
* Two outcome measures are only weakly correlated
corr q1_num_global teach_consensus teach_with_debate [aw = anal_wt]

*****************************************************
********************* ANALYSIS **********************

* Self-selection into coursework

* Non-parametric (crosstab)
** TABLE S2: Distribution of course exposure to climate science (column percentages) by political party identification (see section 3e for wording).

svy: tab college_summary left_party , col pearson percent

** TABLE S3: Distribution of course exposure to climate science (column percentages) by small/big-government ideology (see section 3e for wording). 
svy: tab college_summary q19_govrole, col pearson percent


* Let's just look at entire classes, because it is hard to select into a class
* in which the instructor devotes just one session to climate change.

gen whole_courses = .
replace whole_courses = 0 if college_summary < 3
replace whole_courses = 1 if college_summary == 3
replace whole_courses = 2 if college_summary == 4

tab whole_courses [aw = anal_wt]

svy: ologit whole_courses ib2.left_party 

** TABLE S4: Logistic regression of whole-course exposure to climate science 
** (unstandardized logistic regression slopes with design-corrected standard errors in parentheses). 
svy: ologit whole_courses ib2.left_party q19_govrole


* 1. How does formal education affect teaching practices and content knowledge?

** TABLE S5: Regression of teaching choices on human capital and control variables 
** (unstandardized regression slopes with design-corrected standard errors in parentheses). 
svy: reg q1_num_global   noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible
estimates store m11, title(Class hours)

svy: reg teach_consensus     noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible
estimates store m12, title(Emphasize consensus)

svy: reg teach_with_debate   noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible
estimates store m13, title(Encourage debate)
* no variables are predictive (r2 ~ .02)


** FIGURE 2: Effects of educational achievements and experiences (deficit model) on teaching choices  
#delimit ;
coefplot m11, bylabel(Class Hours) || m12, bylabel(Teach Consensus) || m13, bylabel(Encourage Debate) ||  
, drop(_cons q25_yrsteach female 1.subject 2.subject 3.subject 4.subject q28_black q28_hisp bible) 
xline(0) scheme(s1mono)

;

#delimit cr


/*

#delimit ;
coefplot m1, bylabel(Class Hours) || m2, bylabel(Teach Consensus) || m3, bylabel(Encourage Debate) || 
m4, bylabel(Subject Knowledge) || 
, drop(_cons q25_yrsteach female 1.subject 2.subject 3.subject 4.subject q28_black q28_hisp bible) 
xline(0) scheme(s1mono)

;

#delimit cr

*/


estout m11 m12 m13 using "C:\Users\exp12\Box Sync\Climate (exp12@psu.edu)\_Human capital of US sicence teachers\Jan-14-Table-1.txt" ///
, cells(b(star fmt(2)) se(par(`"="("' `")""') fmt(2))) stardetach baselevels ///
   legend label varlabels(_cons Constant)               ///
   stats(N r2 , fmt(0 2) label(N R-sqr ))
   
* Predicting knowledge in 0 - 100 format

*For Figure 

gen govrole_1_1 = (((q19_govrole -1) / 3) - 1)
sum govrole_1_1
label variable govrole_1_1 "Small- or Big-government ideology"
histogram govrole_1_1, discrete percent xtitle(" ") xlabel(-1(1)1, labels) scheme(s1mono)


svy: regress know4_00           noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible
estimates store m20, title(Content knowledge)

** TABLE S6: Regression of subject knowledge on human capital, political and control variables 
** (unstandardized regression slopes with design-corrected standard errors in parentheses).

svy: regress know4_00           noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible govrole_1_1 ib2.left_party
estimates store m21, title(Content knowledge)


** FIGURE 3: Effects of educational achievements and experiences (left panel), plus political orientation (right panel) 
**  on subject content knowledge 
#delimit ;
coefplot m20, bylabel(Subject Knowledge) || m21, bylabel(Subject Knowledge),  
, drop(_cons q25_yrsteach female 1.subject 2.subject 3.subject 4.subject q28_black q28_hisp bible) 
xline(0) scheme(s1mono) 
;

#delimit cr

 
* 3. How does teacher political orientation predict knowledge and teaching practices?

* Standardize knowledge for 3 last plots
egen know4_z = std(know4_00), mean(0) std(1)
label variable know4_z "Subject Content Knowledge (Z)"
sum know4_z


** TABLE S7: Regression of three teaching choices on human capital, political and control variables 
** (unstandardized regression slopes with design-corrected standard errors in parentheses).

svy: regress q1_num_global  noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible know4_z govrole_1_1 ib2.left_party
estimates store m22, title(Class hours)

svy: regress teach_consensus    noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible know4_z govrole_1_1 ib2.left_party
estimates store m23, title(Emphasize consensus)

svy: regress teach_with_debate  noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female q28_black q28_hisp bible know4_z govrole_1_1 ib2.left_party
estimates store m24, title(Encourage debate)


** FIGURE 4: Effects of educational achievements and experiences, and political orientation (ideology model) on teaching choices
#delimit ;
coefplot m22, bylabel(Class Hours) || m23, bylabel(Teach Consensus) ||  
m24, bylabel(Encourage Debate) || 
, drop(_cons q25_yrsteach female 1.subject 2.subject 3.subject 4.subject q28_black q28_hisp bible) 
xline(0) scheme(s1mono) 
;

#delimit cr




estout m21 m22 m23 m24 using "C:\Users\exp12\Box Sync\Climate (exp12@psu.edu)\_Human capital of US sicence teachers\Jan-14-Table-2.txt" ///
, cells(b(star fmt(2)) se(par(`"="("' `")""') fmt(2))) stardetach baselevels ///
   legend label varlabels(_cons Constant)               ///
   stats(N r2 , fmt(0 2) label(N R-sqr ))

   
   **********************************************************************
**** INTERACTIONS

** TABLE S8: Baseline content knowledge model plus interactions of coursework (here treated as 1-5 numeric summary) with ideology and partisanship
 * Predicting knowledge
svy: regress know4_00       c.govrole_1_1##c.college_summary    noscience_degree gradscience_degree othgrad_degree  i.subject q25_yrsteach female q28_black q28_hisp bible  ib2.left_party
estimates store mi7, title(Content knowledge)

svy: regress know4_00       ib2.left_party##c.college_summary    noscience_degree gradscience_degree othgrad_degree  i.subject q25_yrsteach female q28_black q28_hisp bible govrole_1_1 
estimates store mi8, title(Content knowledge)

estout mi7 mi8  using "C:\Users\exp12\Box Sync\Climate (exp12@psu.edu)\_Human capital of US sicence teachers\Int_know.txt" ///
, cells(b(star fmt(2)) se(par(`"="("' `")""') fmt(2))) stardetach baselevels ///
   legend label varlabels(_cons Constant)               ///
   stats(N r2 , fmt(0 2) label(N R-sqr ))


 * Predicting outcomes
 svy: reg q1_num_globalwarm  c.know4_z##c.govrole_1_1 noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female bible ib2.left_party
 estimates store mi1, title(Class hours)
 svy: reg q1_num_globalwarm  c.know4_z##ib2.left_party noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female bible govrole_1_1
 estimates store mi2, title(Class hours)

 svy: reg teach_consensus  c.know4_z##c.govrole_1_1 noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female bible ib2.left_party
 estimates store mi3, title(Emphasize consensus)
 svy: reg teach_consensus  c.know4_z##ib2.left_party noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female bible govrole_1_1
 estimates store mi4, title(Emphasize consensus)
 * libertarians somewhat in expected direction but dems in wrong direction

 svy: reg teach_with_debate  c.know4_z##c.govrole_1_1 noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female bible ib2.left_party
  estimates store mi5, title(Encourage debate)
  svy: reg teach_with_debate  c.know4_z##ib2.left_party noscience_degree gradscience_degree othgrad_degree i.college_summary i.subject q25_yrsteach female bible govrole_1_1
  estimates store mi6, title(Encourage debate)
  
  * both non sig
  
estout mi1 mi2 mi3 mi4 mi5 mi6 using "C:\Users\exp12\Box Sync\Climate (exp12@psu.edu)\_Human capital of US sicence teachers\Interactions.txt" ///
, cells(b(star fmt(2)) se(par(`"="("' `")""') fmt(2))) stardetach baselevels ///
   legend label varlabels(_cons Constant)               ///
   stats(N r2 , fmt(0 2) label(N R-sqr ))
